package com.ch.nettyplus.client.autoconfigure;

import com.ch.nettyplus.core.toolkit.Constants;
import io.netty.handler.logging.LogLevel;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.concurrent.TimeUnit;

/**
 * @author CH
 * @data 2022/1/7
 */
@Data
@Accessors(chain = true)
@ConfigurationProperties(prefix = Constants.NETTY_PLUS_CLIENT)
public class NettyPlusClientProperties {
    /**
     * 工作线程数 默认为 8
     */
    private short workThreads = 8;
    /**
     * 启用状态
     */
    private boolean status = true;
    /**
     * 绑定端口
     */
    private Integer post = 9999;

    private String host = "127.0.0.1";
    /**
     * netty日志打印配置
     */
    private LogProperties log = new LogProperties();
    /**
     * 心跳处理配置
     */
    private HeartProperties heart = new HeartProperties();

    @Data
    @Accessors(chain = true)
    public static class  LogProperties{
        private boolean status = false;
        private LogLevel logLevel = LogLevel.WARN;
    }

    @Data
    @Accessors(chain = true)
    public static class  HeartProperties{
        /**
         * 是否开启
         */
        private boolean status = false;
        /**
         * 读
         */
        private Long readerIdleTime = 0L;
        /**
         * 写
         */
        private Long writerIdleTime = 0L;
        /**
         * 全（读/写）
         */
        private Long allIdleTime = 0L;
        /**
         * 时间单位
         */
        private TimeUnit timeUnit = TimeUnit.SECONDS;
    }
}
